Distribution
************

Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the same conditions as for modified
versions.

Search and Replace
------------------

   See Groundwork, for Ex address syntax. See Options to see
how to get literal (non-regular-expression) search and how to stop
search from wrapping around.

`<count>  /<string>'
     To the <count>th occurrence of <string>.

`<count>  ?<string>'
     To the <count>th previous occurrence of <string>.

`<count>  g<move>'
     Search for the text described by move. (off by default)

`n'
     Repeat latest `/' `?' (next).

`N'
     Idem in opposite direction.

`%'
     Find the next bracket and go to its match

`:[x,y]g/<string>/<cmd>'
     Search globally [from line x to y] for <string> and execute the Ex
     <cmd> on each occurrence.

`:[x,y]v/<string>/<cmd>'
     Execute <cmd> on the lines that don't match.

`#g<move>'
     Execute the last keyboard macro for each line in the region.
     See Macros and Registers, for more info.

`Q'
     Query Replace.

`:ta <name>'
     Search in the tags file where <name> is defined (file, line), and
     go to it.

`:[x,y]s/<p>/<r>/<f>'
     Substitute (on lines x through y) the pattern <p> (default the last
     pattern) with <r>.  Useful flags <f> are `g' for `global' (i.e.
     change every non-overlapping occurrence of <p>) and `c' for
     `confirm' (type `y' to confirm a particular substitution, else
     `n').  Instead of `/' any punctuation character other than <space>
     <tab> and <lf> can be used as delimiter.

`&'
     Repeat latest Ex substitute command, e.g. `:s/wrong/right'.

`:global /<pattern>/<ex-command>'
`:g /<pattern>/<ex-command>'
     Execute <ex-command> on all lines that match <pattern>.

`:vglobal /<pattern>/<ex-command>'
`:v /<pattern>/<ex-command>'
     Execute <ex-command> on all lines that do not match <pattern>.

Yanking
-------

`<count>  y<move>'
     Yank from begin to endpoint of <count><move>.

`<count>  "<a-z>y<move>'
     Yank from begin to endpoint of <count><move> to register.

`<count>  "<A-Z>y<move>'
     Yank from begin to endpoint of <count><move> and append to
     register.

`<count>  yy'
     <count> lines.

`<count>  Y'
     Idem (should be equivalent to `y$' though).

`m<a-z>'
     Mark the cursor position with a letter.

`[<a-z>'
     Show contents of textmarker.

`]<a-z>'
     Show contents of register.

`<count>  ["<a-z1-9>]p'
     Put the contents of the (default undo) buffer <count> times after
     the cursor. The register will be automatically down-cased.

`<count>  ["<a-z1-9>]P'
     Put the contents of the (default undo) buffer <count> times before
     the cursor. The register will

Undoing
-------

`u U'
     Undo the latest change.

`.'
     Repeat undo.

`:q!'
     Quit Vi without writing.

`:e!'
     Re-edit a messed-up file.

`:rec'
     Recover file from autosave. Viper also creates backup files that
     have a `~' appended to them.

Display
=======

`C-g'
     At user level 1, give file name, status, current line number and
     relative position.
     At user levels 2 and higher, abort the current command.

`C-c g'
     Give file name, status, current line number and relative position
     - all user levels.

`C-l'
     Refresh the screen.

`<count> C-e'
     Expose <count> more lines at bottom, cursor stays put (if
     possible).

`<count> C-y'
     Expose <count> more lines at top, cursor stays put (if possible).

`<count> C-d'
     Scroll <count> lines downward (default the number of the previous
     scroll; initialization: half a page).

`<count> C-u'
     Scroll <count> lines upward (default the number of the previous
     scroll; initialization: half a page).

`<count> C-f'
     <count> pages forward.

`<count> C-b'
     <count> pages backward (in older versions `C-b' only works without
     count).

`<count> z<cr>'

`zH'
     Put line <count> at the top of the window (default the current
     line).

`<count> z-'

`zL'
     Put line <count> at the bottom of the window (default the current
     line).

`<count> z.'

`zM'
     Put line <count> in the center of the window (default the current
     line).

File and Buffer Handling
========================

   In all file handling commands, space should be typed before entering
the file name. If you need  to type a modifier, such as `>>' or `!',
don't put any space between the command and the modifier.

`:q'
     Quit buffer except if modified.

`:q!'
     Quit buffer without checking. In Viper, these two commands are
     identical. Confirmation is required if exiting modified buffers
     that visit files.

`:suspend'

`:stop'
     Suspend Viper

`:[x,y] w'
     Write the file. Viper makes sure that a final newline is always
     added to any file where this newline is missing. This is done by
     setting Emacs variable `require-final-newline' to `t'. If you
     don't like this feature, use `setq-default' to set
     `require-final-newline' to `nil'. This must be done in `.viper'
     file.

`:[x,y] w <name>'
     Write to the file <name>.

`:[x,y] w>> <name>'
     Append the buffer to the file <name>.  There should be no space
     between `w' and `>>'. Type space after the `>>' and see what
     happens.

`:w! <name>'
     Overwrite the file <name>. In Viper, `:w' and `:w!' are identical.
     Confirmation is required for writing to an existing file (if this
     is not the file the buffer is visiting) or to a read-only file.

`:x,y w <name>'
     Write lines x through y to the file <name>.

`:wq'
     Write the file and kill buffer.

`:r <file> [<file> ...]'
     Read file into a buffer, inserting its contents after the current
     line.

`:xit'
     Same as `:wq'.

`:Write'
`:W'
     Save all unsaved buffers, asking for confirmation.

`:WWrite'
`:WW'
     Like `W', but without asking for confirmation.

`ZZ'
     Save current buffer and kill it. If user level is 1, then save all
     files and kill Emacs. Killing Emacs is the wrong way to use it, so
     you should switch to  higher user levels as soon as possible.

`:x [<file>]'
     Save and kill buffer.

`:x! [<file>]'
     `:w![<file>]' and `:q'.

`:pre'
     Preserve the file - autosave buffers.

`:rec'
     Recover file from autosave.

`:f'
     Print file name and lines.

`:cd [<dir>]'
     Set the working directory to <dir> (default home directory).

`:pwd'
     Print present working directory.

`:e [+<cmd>] <files>'
     Edit files. If no filename is given, edit the file visited by the
     current buffer. If buffer was modified or the file changed on
     disk, ask for confirmation. Unlike Vi, Viper allows `:e' to take
     multiple arguments.  The first file is edited the same way as in
     Vi. The rest are visited in the usual Emacs way.

`:e! [+<cmd>] <files>'
     Re-edit file. If no filename, re-edit current file.  In Viper,
     unlike Vi, `e!' is identical to `:e'. In both cases, the user is
     asked to confirm if there is a danger of discarding changes to a
     buffer.

`:q!'
     Quit Vi without writing.

`C-^'
     Edit the alternate (normally the previous) file.

`:rew'
     Obsolete

`:args'
     List files not shown anywhere with counts for next

`:n [count]  [+<cmd>] [<files>]'
     Edit <count> file, or edit files. The count comes from :args.

`:N [count] [+<cmd>] [<files>]'
     Like `:n', but the meaning of the variable EX-CYCLE-OTHER-WINDOW
     is reversed.

`:b'
     Switch to another buffer. If EX-CYCLE-OTHER-WINDOW is `t', switch
     in another window. Buffer completion is supported.

`:B'
     Like `:b', but the meaning of EX-CYCLE-OTHER-WINDOW is reversed.

`:<address>r <name>'
     Read the file <name> into the buffer after the line <address>.

`v, V, C-v'
     Edit a file in current or another window, or in another frame.
     File name is typed in Minibuffer. File completion and history are
     supported.

Mapping
=======

`:map <string>'
     Start defining a Vi-style keyboard macro.  For instance, typing
     `:map www' followed by `:!wc %' and then typing `C-x )' will cause
     `www' to run wc on current file (Vi replaces `%' with the current
     file name).

`C-x )'
     Finish defining a keyboard macro.  In Viper, this command
     completes the process of defining all keyboard macros, whether
     they are Emacs-style or Vi-style.  This is a departure from Vi,
     needed to allow WYSIWYG mapping of keyboard macros and to permit
     the use of function keys and arbitrary Emacs functions in the
     macros.

`:unmap <string>'
     Deprive <string> of its mappings in Vi state.

`:map! <string>'
     Map a macro for Insert state.

`:unmap! <string>'
     Deprive <string> of its mapping in Insert state (see `:unmap').

`@<a-z>'
     In Vi state, execute the contents of register as a command.

`@@'
     In Vi state, repeat last register command.

`@#'
     In Vi state, begin keyboard macro. End with @<a-z>. This will put
     the macro in the proper register. Register will be automatically
     down-cased.  See Macros and Registers, for more info.

`@!<a-z>'
     In Vi state, yank anonymous macro to register

`*'
     In Vi state, execute anonymous macro (defined by C-x( and C-x )).

`C-x e'
     Like `*', but works in all Viper states.

`#g<move>'
     Execute the last keyboard macro for each line in the region.
     See Macros and Registers, for more info.

`[<a-z>'
     Show contents of textmarker.

`]<a-z>'
     Show contents of register.

Shell Commands
==============

   Note that % is used in Ex commands to mean current file. If you want
a % in your command, it must be escaped as `\%'.  However if % is the
first character, it stands as the address for the whole file.
Similarly, `#' expands to the previous file. The previous file is the
first file in `:args' listing. This defaults to the previous file in
the VI sense if you have one window.

`:sh'
     Execute a subshell in another window

`:[x,y]!<cmd>'
     Execute a shell <cmd> [on lines x through y; % is replace by
     current file, \% is changed to %

`:[x,y]!! [<args>]'
     Repeat last shell command [and append <args>].

`:!<cmd>'
     Just execute command and display result in a buffer.

`:!! <args>'
     Repeat last shell command and append <args>

`<count> !<move><cmd>'
     The shell executes <cmd>, with standard input the lines described
     by <count><move>, next the standard output replaces those lines
     (think of `cb', `sort', `nroff', etc.).

`<count> !!<cmd>'
     Give <count> lines as standard input to the shell <cmd>, next let
     the standard output replace those lines.

`:[x,y] w !<cmd>'
     Let lines x to y be standard input for <cmd> (notice the <sp>
     between `w' and `!').

`:<address>r !<cmd>'
     Put the output of <cmd> after the line <address> (default current).

`:<address>r <name>'
     Read the file <name> into the buffer after the line <address>
     (default current).

Options
=======

`autoindent'
`ai'
     autoindent - In append mode after a <cr> the cursor will move
     directly below the first character on the previous line.  This
     setting affects the current buffer only.

`autoindent-global'
`ai-global'
     Same as `autoindent', but affects all buffers.

`noautoindent'
`noai'
     Cancel autoindent.

`noautoindent-global'
`noai-g'
     Cancel autoindent-global.

`ignorecase'
`ic'
     ignorecase - No distinction between upper and lower cases when
     searching.

`noignorecase'
`noic'
     Cancel ignorecase.

`magic'
`ma'
     Regular expressions used in searches; nomagic means no regexps.

`nomagic'

`noma'
     Cancel magic.

`readonly'
`ro'
     readonly - The file is not to be changed.  If the user attempts to
     write to this file, confirmation will be requested.

`noreadonly'
`noro'
     Cancel readonly.

`shell=<string>'
`sh=<string>'
     shell - The program to be used for shell escapes (default `$SHELL'
     (default `/bin/sh')).

`shiftwidth=<count>'
`sw=<count>'
     shiftwidth - Gives the shiftwidth (default 8 positions).

`showmatch'
`sm'
     showmatch - Whenever you append a `)', Vi shows its match if it's
     on the same page; also with `{' and `}'.  If there's no match, Vi
     will beep.

`noshowmatch'
`nosm'
     Cancel showmatch.

`tabstop=<count>'
`ts=<count>'
     tabstop - The length of a <ht>; warning: this is only IN the
     editor, outside of it <ht>s have their normal length (default 8
     positions).  This setting affects the current buffer only.

`tabstop-global'
`ts-g'
     Same as `tabstop', but affects all buffers.

`wrapmargin=<count>'
`wm=<count>'
     wrapmargin - In append mode Vi automatically puts a <lf> whenever
     there is a <sp> or <ht> within <wm> columns from the right margin.

`wrapscan'
`ws'
     wrapscan - When searching, the end is considered `stuck' to the
     begin of the file.

`nowrapscan'
`nows'
     Cancel wrapscan.

`:set <option>'
     Turn <option> on.

`:set no<option>'
     Turn <option> off.

`:set <option>=<value>'
     Set <option> to <value>.

Emacs Related Commands
======================

`C-\'
     Begin Meta command in Vi or Insert states. Most often used as C-\
     x (M-x).

     Note: Emacs binds `C-\' to a function that offers to change the
     keyboard input method in the multilingual environment. Viper
     overrides this binding. However, it is still possible to switch
     the input method by typing `\ C-\' in the Vi command state and
     `C-z \ C-\' in the Insert state.  Or you can use the MULE menu on
     the menubar.

`C-z'
     In Insert and Replace states, prepare Viper to accept the next
     command and execute it as if Viper was in Vi state. Then return to
     Insert state.

     In Vi state, switch to Emacs state; in Emacs state, switch to Vi
     state.

`C-c \'
     Switches to Vi state for the duration of a single command. Then
     goes back to the original Viper state. Works from Vi, Insert,
     Replace, and Emacs states.

`C-x0'
     Close Window

`C-x1'
     Close Other Windows

`C-x2'
     Split Window

`C-xo'
     Move among windows

`C-xC-f'
     Emacs find-file, useful in Insert state

`C-y'
     Put back the last killed text. Similar to Vi's `p', but also works
     in Insert and Replace state. This command doesn't work in Vi
     command state, since this binding is taken for something else.

`M-y'
     Undoes the last `C-y' and puts another kill from the kill ring.
     Using this command, you can try may different kills until you find
     the one you need.

Mouse-bound Commands
====================

   The following two mouse actions are normally bound to to special
search and insert commands in of Viper:

`S-mouse-1 (Emacs)'

`meta button1up (XEmacs)'
     Holding Shift (or Meta, if XEmacs) and clicking mouse button 1 will
     initiate search for a region under the mouse pointer.  This
     command can take a prefix argument. Note: Viper sets this binding
     only if this mouse action is not already bound to something else.
     See Viper Specials, for more information.

`S-mouse-2 (Emacs)'

`meta button2up (XEmacs)'
     Holding Shift (or Meta, if XEmacs) and clicking button 2 of the
     mouse will insert a region surrounding the mouse pointer.  This
     command can also take a prefix argument.  Note: Viper sets this
     binding only if this mouse action is not already bound to
     something else.  See Viper Specials, for more details.

Acknowledgments
***************

   Viper, formerly known as VIP-19, was written by Michael Kifer. Viper
is based on the original VIP package by Masahiko Sato and on its
enhancement, VIP 4.4, by Aamod Sane. This manual is an adaptation of
the manual for VIP 4.4, which, in turn, was based on Sato's manual for
VIP 3.5.

   Many contributors on the net pointed out bugs and suggested a number
of useful features. Here is a (hopefully) complete list of contributors:

     ahg@panix.com (Al Gelders),
     amade@diagram.fr (Paul-Bernard Amade),
     ascott@fws214.intel.com (Andy Scott),
     cook@biostat.wisc.edu (Tom Cook),
     csdayton@midway.uchicago.edu (Soren Dayton),
     dave@hellgate.utah.edu,
     dwallach@cs.princeton.edu (Dan Wallach),
     dwight@toolucky.llnl.gov (Dwight Shih),
     edmonds@edmonds.home.cs.ubc.ca (Brian Edmonds),
     gviswana@cs.wisc.edu (Guhan Viswanathan),
     gvr@halcyon.com (George V. Reilly),
     hatazaki@bach.convex.com (Takao Hatazaki),
     hpz@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld),
     jackr@dblues.engr.sgi.com (Jack Repenning),
     jamesm@bga.com (D.J. Miller II),
     jjm@hplb.hpl.hp.com (Jean-Jacques Moreau),
     jl@cse.ogi.edu (John Launchbury),
     jobrien@hchp.org (John O'Brien),
     johnw@borland.com (John Wiegley),
     kanze@gabi-soft.fr (James Kanze),
     kin@isi.com (Kin Cho),
     kwzh@gnu.ai.mit.edu (Karl Heuer),
     lindstro@biostat.wisc.edu (Mary Lindstrom),
     Mark.Bordas@East.Sun.COM (Mark Bordas),
     meyering@comco.com (Jim Meyering),
     mrb@Eng.Sun.COM (Martin Buchholz),
     mveiga@dit.upm.es (Marcelino Veiga Tuimil),
     paulk@summit.esg.apertus.com (Paul Keusemann),
     pfister@cs.sunysb.edu (Hanspeter Pfister),
     phil_brooks@MENTORG.COM (Phil Brooks),
     pogrell@informatik.hu-berlin.de (Lutz Pogrell),
     pradyut@cs.uchicago.edu (Pradyut Shah),
     roderick@argon.org (Roderick Schertler),
     rxga@ulysses.att.com,
     sawdey@lcse.umn.edu (Aaron Sawdey),
     simonb@prl.philips.co.uk (Simon Blanchard),
     sudish@MindSpring.COM (Sudish Joseph),
     schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
     terra@diku.dk (Morten Welinder),
     thanh@informatics.muni.cz (Han The Thanh),
     toma@convex.convex.com,
     vrenjak@sun1.racal.com (Milan Vrenjak),
     whicken@dragon.parasoft.com (Wendell Hicken),
     zapman@cc.gatech.edu (Jason Zapman II),